Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Query artifacts that have a specific attribute value via API in DOORS Next Generation 7.0.3

Is it possible to query for artifacts that have a specific value in one of their attributes via an API call? For example, query for artifacts in a specific project in a specific stream that have value "ID1" in their "Work Item ID" attribute. Or query for artifacts in a specific project in a specific stream that have a non empty value in their "Work Item ID" attribute.

0 votes


Accepted answer

Permanent link
Yes you can use OSLC Query to filter results by the value of one or more attributes. The filters are ‘and’ed. Attribute values for attributes included in the oslc.select are returned in the results.

But no the OSLC Query specification can't test for empty or non-empty attributes - you have to get the value (using oslc.select) and then filter afterwards.

Joshua Baxter selected this answer as the correct answer

2 votes

Comments

Is it possible to query for artifacts that have an attribute value that starts with a specific value? For example, query for artifacts where the value for the Work Item attribute starts with the string "WorkId". 

No I don't think this is possible - you'll have to get the attribute value and post-process looking for what you want.

1 vote

For future reference, is there a URL that displays all the possible query parameters that you can use in DNG 7.0.3 OSLC queries? The Using OSLC capabilities in the Requirements Management application only has a small amount of examples and was created in 2013. 

The OSLC Query specification https://docs.oasis-open-projects.org/oslc-op/query/v3.0/os/oslc-query.html hasn’t changed a lot. It gives the full picture of what might be possible. AFAIK DOORS Next uses the oslc.where, oslc.select, oslc.prefix and (since a fairly recent version that I can’t specify but should work in 7.0.3) oslc.searchTerms parameters. AFAIK oslc.searchTerms matches only against the primary content.

1 vote

As a soft entry into OSLC Query you might want to look at https://github.com/IBM/ELM-Python-Client which has an oslcquery command that lets you work with Query at a human-friendly level, i.e. without having to deal with the details of how Query works in terms of HTTP GET URLs. oslcquery may not do everything you might want to do but it’s OSS and you can modify/extend/contribute :-)

Thanks for the resources. I'm assuming that it's not possible to query for artifacts that have a specific attribute value if it is a custom attribute that we have created since if I understand correctly can only query for attribute types that are listed at http://purl.org/dc/terms/ ?

Also from following the OSLC examples I tried to query for artifacts that are in a specific module with ID 1294667https://server/rm/views?oslc.query=true&projectURL=value&oslc_config.context=value&oslc.prefix=oslc_rm=<http://open-services.net/ns/rm%23>,dcterms=<http://purl.org/dc/terms/>&oslc.select=oslc_rm:uses&oslc.where=dcterms:identifier=1294667

However I got the following error: com.ibm.oslc.query.parser.select.ParseException: Invalid prefix definition: oslc_rm

I'm suspicious of the url in your oslc.prefix oslc_rm=<http://open-services.net/ns/rm%23> - the encoding looks wrong, the %23 should be a #.. Also in the actual URL all the query parameter values MUST be url-encoded not plaintext like you're showing - so for your query I'd expect the actual URL too look like https://server/rm/views?oslc.query=true&projectURL=value&oslc_config.context=value&oslc.prefix=oslc_rm%3D%3Chttp%3A%2F%2Fopen-services.net%2Fns%2Frm%23%3E,dcterms%3D%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Fterms%2F%3E&oslc.select=oslc_rm%3Auses&oslc.where=dcterms%3Aidentifier%3D1294667


1 vote

Yes it is possible to query custom attributes, you need to know the type URI and convert it to a prefixed name (adding the prefix to the oslc.prefix too), and if the comparison is with e.g. an enumeration value then in the query you use the URI of the enumeration value.
Finding these URIs can be complicated you can see the shapes in the services.xml.
But for example if I define a custom attribute OriginID which is ineger then I can query for value 23 with a URL (decoded) which includes:

oslc.where=rp0:AD_QFRd4KG4Ee-bktCwEBzc1A=23
oslc.select=rp0:AD_QFRd4KG4Ee-bktCwEBzc1A,dcterms:identifier,rm_nav:parent

1 vote

Thanks for your responses. I will try out your suggestion to see if it fixes my error. And thanks for confirming that you can query for custom attributes. I have another question. I know you can query for global streams in GCM via API, as well as create global streams via API as how to do that is detailed at this link. But is it possible to query for local streams that are in a Doors Next project via API, as well as create local streams in Doors next via API?

Please submit that as a new question and I'll answer

1 vote

@Ian - regarding your comment talking about the %23, that's the URL encoded # symbol. You can't include it directly in the query parameters as it's also use for the anchor and so it'll cause errors in the URL

@Ian Barnard, regarding your comment on how to query for custom attributes, I got the services.xml for the component. In that services.xml there are multiple <oslc:resourceShape> entries. For example one <oslc:CreationFactory> entry called "Requirement Creation Factory" has 6 <oslc:resourceShape> entries, and another <oslc:CreationFactory> entry called "Collection Creation Factory" has  3 <oslc:resourceShape> entries. I called all of the <oslc:resourceShape> entries URLs but none of them had anything pertaining to the custom attribute that we created, so I'm not sure where I would find the "shape" for it. Our custom attribute is a string.


Also I see that when calling the <oslc:resourceShape> URLs, there are multiple entries in the results. I'm assuming that the URL in the <oslc:propertyDefinition> would be what I would need to include in the oslc.prefix value for the query?


Also, I'm assuming that custom attributes that we created can be included in the oslc.select parameter for OSLC queries as well?

One of the resourceShape URLs is the artifact type of your artifact. The artifact type references all the attribute types - one of these is the URI you need for your oslc.select entry.


showing 5 of 17 show 12 more comments

One other answer

Permanent link
You should be able to use the oslc.where parameter to filter dynamically, for example:

1 vote

Comments

I'll take a look at that, thanks. So you can query for a certain value, but is it possible to query for if an attribute's value is not empty? For example, query for artifacts in project where a "State" attribute is not empty? Is it possible to specify the stream in the query? I didn't see any examples at Using OSLC capabilities in the Requirements Management application that showed how to specify the stream in a query.

Yes, you can use != or <> from memory

For some stupid reason I can't add the solution to how you reference a stream because the forum won't let me save the post, saying it's got invalid text :-(

Thanks for your response. I'm assuming it's not possible to include more than one stream/config in the oslc_config:context/oslc_config:configuration parameters?

No - and it wouldn't make sense to, as the context of artefacts has to be within the requested stream. You wouldn't be able to untangle the various versions of each artefact

1 vote

Agree with Davyd - you can’t use a list of configs - but you can use a global configuration and get results from the RM components contributing to that GC. From a pragmatic perspective, for this to work in terms of types in the different components, you need to have diligently applied URIs on all types. For background on this refer to https://jazz.net/library/article/92352

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,939

Question asked: Nov 06 '24, 5:57 p.m.

Question was seen: 560 times

Last updated: Nov 21 '24, 8:28 a.m.

Confirmation Cancel Confirm